#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <unordered_set>
using namespace std;

class Solution {
public:
  int lengthOfLongestSubstring(string s) {
    // int flag[25];
    // memset(flag, 0, sizeof(flag));
    unordered_set<char> flag;
    int res = 0;
    for (int i = 0, j = 0; j < s.size(); ++j) {
      while (flag.find(s[j]) != flag.end() && i <= j) {
        flag.erase(s[i]);
        i++;
      }
      res = max(res, j - i + 1);
      flag.emplace(s[j]);
    }
    return res;
  }
};

int main() {
  Solution *s = new Solution;
  int a = s->lengthOfLongestSubstring(" ");
  return 0;
}